package lab03.Test09;
import java.io.*;
import java.util.ArrayList;
/**
 * Created by Administrator on 2017/12/13.
 */
public class BookList {
    ArrayList<Book> book=new ArrayList<Book>();
    void readerAndWrite(){
        try {
            FileReader in=new FileReader("E\\java123\\pbookinfo.txt");
            BufferedReader reader=new BufferedReader(in);
            FileWriter out=new FileWriter("E\\java123\\book\\pbookinfonew.txt");
            BufferedWriter writer=new BufferedWriter(out);
            String string=reader.readLine();
            writer.write(string+"\r\n");
            while ((string=reader.readLine())!=null){
                String str[]=string.split("\\s{2,}");
                book.add(new Book(str[0],str[1],str[2],str[3],str[4]));}
            book.get(2).increasePrice(20);
            book.get(3).increasePrice(30);
            for (int i=0;i<book.size();i++){
                writer.write(book.get(i).toString());}
            reader.close();
            writer.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();}}
    public static void main(String[] args) {
        BookList book=new BookList();
        book.readerAndWrite();}}
